<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:s="http://jboss.org/schema/seam/taglib"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:a="http://richfaces.org/a4j" xmlns:p="http://primefaces.org/ui"
	template="/layout/template.xhtml">

	<ui:define name="body">

		<h:form styleClass="edit">

			<p:panel>
				<f:facet name="header">
				Simulado &gt; #{simuladoHome.simuladoId}  &gt;
				#{empty simuladoHome.questao.id ? 'Add' : 'Edit'} Questão &gt; #{empty simuladoHome.questao.id ? 'Nova' : simuladoHome.questao.id} </f:facet>

				<div class="fields">


					<s:label styleClass=" #{invalid?'errors':''} label" for="descricao">
						<h:outputText value="Enunciado" />
						<s:span styleClass="required" rendered="#{required}">*</s:span>
					</s:label>
					<div style="clear: both" />

					<span class=" value #{invalid?'errors':''} conteudo "> <s:validateAll>
							<p:editor id="descricao"
								value="#{simuladoHome.questao.descricao}">
								<f:converter converterId="br.com.simulador.TextConverter"></f:converter>
							</p:editor>

						</s:validateAll> <span class="error"> <h:graphicImage
								value="/img/error.gif" rendered="#{invalid}" styleClass="errors" />
							<s:message styleClass="errors" />
					</span>
					</span>
				</div>


				<s:decorate id="tagsField" template="/layout/edit.xhtml">
					<ui:define name="label">Tags</ui:define>
					<p:inputText id="simulado_tags"
						value="#{simuladoHome.listTagsQuestao}">

					</p:inputText>
				</s:decorate>
				<s:decorate id="dataCriacaoField" template="/layout/display.xhtml">
					<ui:define name="label">Data criação</ui:define>
					<h:outputText value="#{simuladoHome.questao.dataCriacao}">
						<s:convertDateTime type="both" dateStyle="short" />
					</h:outputText>

				</s:decorate>

				<div style="clear: both">
					<span class="required">*</span>Campos Obrigatórios
				</div>

			</p:panel>



			<p:panel>
				<f:facet name="header">Itens de Questão</f:facet>
				<p:dataTable value="#{listItensQuestao}" var="_itemQuestao"
					rowClasses="rvgRowOne,rvgRowTwo" id="listItensQuestao"
					editable="true" rowIndexVar="row">
					<p:column>
						<f:facet name="header">
							<h:outputText value="#" />
						</f:facet>

						<h:outputText value="#{row+1}" escape="false">

						</h:outputText>
					</p:column>

					<p:column>

						<f:facet name="header">Descrição</f:facet>
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{simuladoHome.itemQuestao.descricao}" />
							</f:facet>
							<f:facet name="input">
								<p:inputText id="descricao"
									value="#{simuladoHome.itemQuestao.descricao}" size="50" />
							</f:facet>
						</p:cellEditor>

					</p:column>
					<p:column>
						<f:facet name="header">Correta</f:facet>
						<p:cellEditor>
							<f:facet name="output">
								<h:outputText value="#{simuladoHome.itemQuestao.correta}" />
							</f:facet>
							<f:facet name="input">
								<center>
									<p:selectBooleanCheckbox
										value="#{simuladoHome.itemQuestao.correta}">
									</p:selectBooleanCheckbox>
								</center>
							</f:facet>
						</p:cellEditor>

					</p:column>
					<p:column style="width:32px">
						<p:rowEditor />
					</p:column>
					<p:column>

						<p:commandButton value="Delete"
							action="#{simuladoHome.deleteItem()}" update="listItensQuestao"
							ajax="true">

							<f:setPropertyActionListener target="#{simuladoHome.itemQuestao}"
								value="#{_itemQuestao}" />
						</p:commandButton>
					</p:column>


				</p:dataTable>

				<div class="actionButtons">
					<p:commandButton id="additemQuestao" value="Novo Item"
						action="#{simuladoHome.newItemQuestao()}"
						update="listItensQuestao">

					</p:commandButton>
				</div>


			</p:panel>



			<div class="actionButtons">
				<p:commandButton id="save" value="Salve"
					action="#{simuladoHome.saveQuestao()}">
					<f:param name="cid" value="#{conversation.id}"></f:param>
					<s:conversationPropagation type="join" />
				</p:commandButton>

				<p:commandButton id="delete" value="Delete"
					action="#{simuladoHome.deleteQuestao()}" immediate="true"
					ajax="false" outcome="/pages/SimuladoEdit.xhtml">
					<f:param name="cid" value="#{conversation.id}"></f:param>
					<s:conversationPropagation type="join" />
				</p:commandButton>

				<p:button id="VoltaEdit" value="Volta" ajax="false"
					outcome="/pages/SimuladoEdit.xhtml">
					<f:param name="cid" value="#{conversation.id}"></f:param>
					<s:conversationPropagation type="join" />
				</p:button>

			</div>

		</h:form>

	</ui:define>




</ui:composition>
